package com.vernhe;

import com.vernhe.circle.CircleDeque;
import com.vernhe.circle.CircleQueue;

import java.util.LinkedList;

public class Main {
    public void test1() {
        //        Queue<Integer> queue = new Queue<>();
//        queue.enQueue(11);
//        queue.enQueue(22);
//        queue.enQueue(33);
//        queue.enQueue(44);

        Deque<Integer> queue = new Deque<>();
        queue.enQueueFront(11);
        System.out.println(queue);
        queue.enQueueFront(22);
        System.out.println(queue);
        queue.enQueueRear(33);
        System.out.println(queue);
        queue.enQueueRear(44);
        System.out.println(queue);
        while (!queue.isEmpty()) {
            System.out.println(queue.deQueueFront());
        }
    }

    public static void test2() {
        CircleQueue<Integer> queue = new CircleQueue();
        for (int i = 0; i < 10; i++) {
            queue.enQueue(i);
        }
        for (int i = 0; i < 5; i++) {
            queue.deQueue();
        }
        for (int i = 15; i < 20; i++) {
            queue.enQueue(i);
        }
        System.out.println(queue);
        while (!queue.isEmpty()) {
            System.out.println(queue.deQueue());
        }
    }

    //[11,7,6,5,4,3,2,1,100,101,102,103,104,105,106,null,null,null,null,null,null,12]
    static void test3() {
        CircleDeque<Integer> queue = new CircleDeque<>();
        for (int i = 0; i < 10; i++) {
            queue.enQueueFront(i+1);
            queue.enQueueRear(i+100);
        }
        for (int i = 0; i < 3; i++) {
            queue.deQueueFront();
            queue.deQueueRear();
        }
        queue.enQueueFront(11);
        queue.enQueueFront(12);
        System.out.println(queue);
        while (!queue.isEmpty()) {
            System.out.println(queue.deQueueFront());
        }
    }

    public static void main(String[] args) {
        test3();
        test2();
    }
}
